﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyVoteMVC.Domain;
using System.Data.Entity.ModelConfiguration;

namespace MyVoteMVC.Data.Mapping
{
    public class VT_LotteriesMap : EntityTypeConfiguration<VT_Lotteries>
    {
        public VT_LotteriesMap()
        {
            // Primary Key
            this.HasKey(t => t.Lottery_ID);

            // Properties
            this.Property(t => t.Lottery_Level)
                .IsRequired();
              
            this.Property(t => t.Ticket_ID)
                   .HasMaxLength(36);

            this.Property(t => t.User_Email)
                .HasMaxLength(100);

            this.Property(t => t.Activity_ID)
              .HasMaxLength(36);

            this.Ignore(t => t.Lottery_Type);

            // Table & Column Mappings
            this.ToTable("VT_Lotteries");
            this.Property(t => t.Lottery_ID).HasColumnName("Lottery_ID");
            this.Property(t => t.Lottery_Level).HasColumnName("Lottery_Level");
            this.Property(t => t.Ticket_ID).HasColumnName("Ticket_ID");

            this.Property(t => t.Created_Date).HasColumnName("Created_Date");
            this.Property(t => t.Lottery_TypeValue).HasColumnName("Lottery_Type");
            this.Property(t => t.User_Email).HasColumnName("User_Email");
            this.Property(t => t.Activity_ID).HasColumnName("Activity_ID");

            this.HasRequired(o => o.Ticket)
                .WithMany(t => t.Lotteries)
                .HasForeignKey(o => o.Ticket_ID);
        }
    }
}
